<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html>
<head>
<title>订单管理</title>

<script language="javascript">
	var recs ="";
var chkid= '';
function rowClick(id)
{
id = id.substring(0,id.length-2);
window.open('__APP__/Order/ShowOrderPage?sn='+$(id+'serial_number').innerHTML);
}

function outme(id){
	chkid = id.substring(0,id.length-3);
		var myWindow7 = function(){
			new MUI.Window({
			id: 'outpage',
			title: '出库页面',
			loadMethod: 'xhr',
			contentURL: '__APP__/Depot/outme',
			width: 420,
			height: 150
			});
			}
		myWindow7();
}	


	function _outme()
	{	
		var myRequest = new Request.JSON({
		method: 'post', 
		url: '__APP__/Depot/_outme',
		headers: 'Content-Type:text/html; charset=utf-8',
		data: 'sn='+$(chkid+'serial_number').innerHTML+'&note='+$('note').value+'&exp_number='+$('exp_number').value+'&orderid='+chkid,
		onSuccess: function(data){
		operdata2(data);
		},
		onFailure: function(){
			$('result').set('text', '您的请求失败了.');
					}	
		}).send(); 		
	}
	
	function operdata2(data){
		if(data[0]['status']=='ok')
		{	
		MochaUI.notification('订单出库完成');
		updateMain('Out Order Success','__SELF__?34');
		$('outpage').dispose();		
		}
		else
		{
		MochaUI.notification(data[0]['msg']);
		}
	}
	
	function req(){
	var recsx= recs; recs='';
	var dt = 'data='+recsx+'&cust_note='+$('cust_note').value+'&express='+$('express').value+'&from='+$('from').value +'&cust_info='+$('cust_info').value;	
		var myRequest = new Request.JSON({
		method: 'post', 
		url: 'index.php/Order/addOrder',
		data: dt,
		headers: 'Content-Type:text/html; charset=utf-8',
		onSuccess: function(data){
			operate9X(data);
		},
		onFailure: function(){
			$('result').set('text', '请求失败.');
				}	
		}).send();
		weight = 0;
		value = 0;
	}
			
	//操作返回的数据
	function operate9X(data){
		recs='';
		if(data[0]['status']=='ok')
		{
		msg('下单完成，自动预览订单'+data[0]['data']+'...');
		$('orderpage').dispose();
		var fstr = "window.open("+"'"+'__APP__/Order/ShowOrderPage?sn='+data[0]['data']+"'"+");";
		fstr = 'updateMain('+"'"+'Record add Success!'+"'"+",'"+'index.php/Order'+"'"+');'+fstr;
		setTimeout(fstr,1000);
		}
		else
		{
		//alert('返回消息：'+data[0]['msg']);
		;$('orderpage').dispose();
		}
	}


	function addRec(s,c,p){
			MochaUI.notification('记录添加成功');
				recs = operSc(s,recs,c,p)
				$('data').value = recs;
				//alert(recs);
				$('order_detail_recs').innerHTML = $('order_detail_recs').innerHTML +"<li>编码："
				+s
				+ "||| 数量："
				+c
				+ "||| 成交金额："
				+p
				+"</li><br/>";
	}



	function OrderWin(){
	var myWindow = function(){
		new MUI.Window({
			id: 'orderpage',
			title: '下单页面',
			loadMethod: 'xhr',
			contentURL: '__URL__/handOrderForm',
			width: 420,
			height: 350
		});
		}
		recs = '';myWindow();	
	}
	
	window.addEvent('load', function(){ 
		initialWin();		
		});	


	function rowClick4(id)
	{	var or_id = id.substring(2);
		var myRequest = new Request.JSON({
		method: 'post', 
		url: '__APP__/Order/getDetailRec',
		headers: 'Content-Type:text/html; charset=utf-8',
		data: 'or_id='+or_id,
		onSuccess: function(data){
			operOrdDetal4(data);
		},
		onFailure: function(){
			$('result').set('text', '您的请求失败了.');
				}	
		}).send(); 
	}
	
	
	function operOrdDetal4(data){
		if(data[0]['status']=='ok')
		{	var len = $chk(data[0]['data'])?data[0]['data'].length :0;	
			if(len>0)
			{
			var htmlstr ='';
				for(i=1;i<=len;i++)
				{
				htmlstr = htmlstr+ '<br/>流水号为:'+data[0]['data'][i-1]['serial_number']+'的订单'+'<br>记录'+i+': 简码'+data[0]['data'][i-1]['simple_code']
				+'数量'+data[0]['data'][i-1]['count']
				+'标准价'+data[0]['data'][i-1]['price']
				+'成交价'+data[0]['data'][i-1]['actual_price']				
				+'</br>';
				}				
			}
			else
			{
			var htmlstr = '<h1>本订单详单数量为0</h1>'

			}
			var myWindow4 = function(){
			new MUI.Window({
				id: 'htmlpage',
				title: '',
				content: htmlstr,
				width: 420,
				height: 150
			});
			}
		myWindow4();
		}
	}

</script>
</head> 
<body>
<!--主页面开始-->
<div id="maindptPage">
<!--显示订单列表开始-->
	<!--显示数据列表-->
	<div id="OrderList" style="text-align:center">
		<!--空记录开始-->
		<if condition="count($orderPreList) elt 0">
		<h3>没有订单数据</h3><br />
		<input type="button" name="bt2" value="同步淘宝订单" class="button" onMouseOver="msg('同步24小时内淘宝已付款订单');" onClick="AsycOrder()">
		</if>
		<!--空记录结束-->	
		<!--数据集显示开始-->
		<!--商品分类编码默认不显示，显示商品列表-->
	
		<input type="button" name="bt2" value="同步淘宝订单" class="button" onMouseOver="msg('同步24小时内淘宝已付款订单');" onClick="AsycOrder()">	
		<input type="button" id="btau" style="display:none;" value="获得Session" class="button" onClick="if($('aukey').value!='')getSession();else{msg('输入授权key');}">	
				<input type="text" id="aukey" style="display:none;" value="请把授权key复制到这里" onClick="this.value='';" size="45" >	
		<input type="button" name="bt22" value="人工下单" class="button" onClick="OrderWin();" id="tb22">
		
		<div id="pdtShow"  >
		<if condition="count($orderPreList) gt 0">
		<h3 style="text-align:center">订单列表</h3>
			<table align="center" bgcolor="#e7efff" width="100%" border="1" cellspacing="1" cellpadding="1" style="font-size:12px;">

                    <tr>
                        <td bgcolor="#FF9933">发货</td>		
                        <td bgcolor="#FF9933">打印</td>						
                        <td bgcolor="#FF9933">详单</td>
                        <td bgcolor="#FF9933">来自</td>	
                        <td bgcolor="#FF9933">客户</td>							
                        <td bgcolor="#FF9933">收货人</td>												
                        <td bgcolor="#FF9933">淘宝订单号</td>							
                        <td bgcolor="#FF9933">支付宝交易号</td>							
                        <td bgcolor="#FF9933">日期</td>							
                        <td bgcolor="#FF9933">流水号</td>	
                        <td bgcolor="#FF9933">客户备注</td>	
                        <td bgcolor="#FF9933">客服备注</td>															
                        <td bgcolor="#FF9933">状态</td>	
	                    <td bgcolor="#FF9933">客服</td>																																																												
                        <td bgcolor="#FF9933">商家</td>	
                        <td bgcolor="#FF9933">总价</td>							
						
                    </tr>
						<div id="orderPreList" >
                          <volist name="orderPreList" id="vo">
                            <tr id="{$vo.id_tb_order}" onMouseOver="this.style.backgroundColor='#f7f7f7'"
							onmouseout="this.style.backgroundColor='transparent'" >
							  <td id="{$vo.id_tb_order}chkboxtd"><img src="__PUBLIC__/Images/go_left.jpg" id="{$vo.id_tb_order}out" onClick="outme(this.id);" /></td>							
							  <td id="{$vo.id_tb_order}chkboxtd"><img src="__PUBLIC__/Images/Print.ico" id="{$vo.id_tb_order}pt" onClick="rowClick(this.id)" /></td>							
							  <td id="{$vo.id_tb_order}"><img src="__PUBLIC__/Images/allow.gif" id="sh{$vo.id_tb_order}" onClick="rowClick4(this.id)" /></td>
                              <td id="{$vo.id_tb_order}date">{$vo.from}</td>
                              <td id="{$vo.id_tb_order}date">{$vo.custmer_id}</td>	
                              <td id="{$vo.id_tb_order}date">{$vo.custmer_name}</td>	
                              <td id="{$vo.id_tb_order}date">{$vo.tid}</td>							  							  
                              <td id="{$vo.id_tb_order}date">{$vo.alipay_no}</td>							  
                              <td id="{$vo.id_tb_order}date">{$vo.date}</td>
                              <td id="{$vo.id_tb_order}serial_number">{$vo.serial_number}</td>
                              <td  width="100" style="overflow:auto" id="{$vo.id_tb_order}cust_note">{$vo.cust_note}</td>
                              <td id="{$vo.id_tb_order}trace_note">{$vo.trace_note}</td>	
                              <td id="{$vo.id_tb_order}status">{$vo.status}</td>							  
                              <td id="{$vo.id_tb_order}conductor_id">{$vo.conductor_id}</td>							  
                              <td id="{$vo.id_tb_order}userid">{$vo.userid}</td>
                              <td id="{$vo.id_tb_order}userid">{$vo.total_value}</td>							  
							 
                            </tr>
                          </volist>
                        </div>
					<tr>
                    <td align="center" colspan="17">		
					<?php
					if(isset($page)) echo $page;		
					?>	</td>
                    </tr>
		  	</table>
		<!--数据集显示结束-->
		</if>
	  </div>
	</div>
		
<!--显示商品列表结束-->
	
</div>
<!--主页面结束-->
</body>
</html>
